package com.haoxiaozi.www.GUIFunctionStudy;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-12-07
 * Time: 16:45
 */
public class BorderLayout {
    public static void main(String[] args) {
        Frame frame = new Frame("Frame");

        //设置为东西南北中布局
        frame.setLayout(new java.awt.BorderLayout());

        frame.setVisible(true);

        frame.setBounds(300,300,500,500);
        frame.setBackground(new Color(169, 110, 110));

        //组件-按键
        Button button1 = new Button("按键1");
        Button button2 = new Button("按键2");
        Button button3 = new Button("按键3");

        //添加按键
        frame.add(button1);
        frame.add(button2);
        frame.add(button3);

        frame.addWindowListener(new WindowAdapter(){
            @Override
            public void windowClosing(WindowEvent e) {
                //结束程序
                System.exit(0);
                e.getSource();
            }
        });
    }
}
